package com.wanmait.schedule.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.schedule.entity.Notice;
import com.wanmait.schedule.entity.NoticeRecord;
import com.wanmait.schedule.entity.Student;
import com.wanmait.schedule.mapper.NoticeRecordMapper;
import com.wanmait.schedule.mapper.StudentMapper;
import com.wanmait.schedule.service.NoticeRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 通知查看记录表 服务实现类
 * </p>
 *
 * @author wanmait
 * @since 2022-12-05
 */
@Service
public class NoticeRecordServiceImpl extends ServiceImpl<NoticeRecordMapper, NoticeRecord> implements NoticeRecordService {

    @Resource
    private NoticeRecordMapper noticeRecordMapper;

    @Override
    public List<NoticeRecord> findNoticeById(Integer id,Integer status) {
        List<NoticeRecord> noticeRecordList = noticeRecordMapper.findNoticeById(id,status);
        return noticeRecordList;
    }

    @Override
    public PageInfo<NoticeRecord> findByStudent(Integer id,Integer pageNum) {
        if(pageNum==null){
            pageNum=1;
        }
        PageHelper.startPage(pageNum,5);
        List<NoticeRecord> byStudent = noticeRecordMapper.findByStudent(id);
        PageInfo<NoticeRecord> pageInfo = new PageInfo<>(byStudent,11);
        return pageInfo;
    }
    @Override
    public PageInfo<NoticeRecord> findByTeacher(Integer id,Integer pageNum){
        if(pageNum==null){
            pageNum=1;
        }
        PageHelper.startPage(pageNum,5);
        List<NoticeRecord> byTeacher = noticeRecordMapper.findByTeacher(id);
        PageInfo<NoticeRecord> pageInfo = new PageInfo<>(byTeacher,11);
        return pageInfo;
    }

    @Override
    public Integer noReader(Integer id, Integer status) {
        Integer noReader = noticeRecordMapper.noReader(id, status);
        return noReader;
    }

    @Override
    public void delete(Integer id) {
        noticeRecordMapper.delete(id);
    }
}
